package com.sskj.aikeeper.hangqing.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.hjq.toast.ToastUtils;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.sskj.aikeeper.R;
import com.sskj.aikeeper.presenter.CertificationPresenter;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.widget.SelectPictureDialog;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author Hey
 * Create at  2019/06/25
 */
@Route(path = RConfig.APP_ACTIVITY_CERTIFICATION)
public class CertificationActivity extends BaseActivity<CertificationPresenter> {

    @BindView(R.id.tvTitle)
    TextView tvTitle;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.et_scanID)
    EditText etScanID;
    @BindView(R.id.btn_confirm)
    Button btnConfirm;

    @Override
    public int getLayoutId() {
        return R.layout.app_activity_certification;
    }

    @Override
    public CertificationPresenter getPresenter() {
        return new CertificationPresenter();
    }

    @Override
    public void initView() {
        tvTitle.setText(App.INSTANCE.getString(R.string.app_certificationActivity1));

    }

    @Override
    public void initData() {
        ClickUtil.click(300, btnConfirm, () -> {
            if (isEmpty(etName)) {
                toastHint(etName);
                return;
            }
            if (isEmpty(etScanID)) {
                toastHint(etScanID);
                return;
            }
            if (getText(etScanID).length() < 14) {
                ToastUtils.show(App.INSTANCE.getString(R.string.app_certificationActivity2));
                return;
            }
            ARouter.getInstance().build(RConfig.APP_ACTIVITY_CERTIFICATION_UPLOAD)
                    .withString(Constans.IDENTITY_NAME, getText(etName))
                    .withString(Constans.IDENTITY_IDCARD, getText(etScanID))
                    .navigation();
            finish();
        });
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, CertificationActivity.class);
        context.startActivity(intent);
    }
}
